package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class<?> c = Class.forName("reflect.Person");
        Method method = c.getMethod("say", String.class, int.class);
        //       Method method = c.getMethod("getName");
        String name = method.getName();
        System.out.println(name);
        int modifiers = method.getModifiers();
        switch (modifiers) {
            case Modifier.PUBLIC:
                System.out.println("public");
                break;
            case Modifier.PRIVATE:
                System.out.println("private");
                break;
            case Modifier.PROTECTED:
                System.out.println("protected");
                break;
            default:
                System.out.println("default");
        }
        Class<?> returnType = method.getReturnType();
        System.out.println(returnType.getName());
        Class<?>[] parameterTypes = method.getParameterTypes();
        for (Class<?> parameterType : parameterTypes) {
            System.out.println(parameterType.getName());
        }
        System.out.println(method.getParameterCount());
    }
}
